#include "Circle.h"
//----------------------------------------------------------------
ns::Circle::Circle (int iNumCaras)
:
Shape()
{
	cantCaras  = iNumCaras;

	//dani comento q dsps de 145 no anda mas...
	if (iNumCaras > 145)
		cantCaras = 145;
}
//----------------------------------------------------------------
void ns::Circle::Draw (Renderer* renderer)
{
	Shape::Draw(renderer);
	renderer->Draw(m_pVertices, PrimitiveType::TriangleFan, iCantVertices);
}
//----------------------------------------------------------------
int ns::Circle::getNumeroCaras()
{
	return cantCaras;
}
//----------------------------------------------------------------
void ns::Circle::drawCircle()
{
	ColorVertex* pV;

	m_pVertices = NULL;
	m_pVertices = new ColorVertex[cantCaras + 2];
	iCantVertices = cantCaras + 2;

	// = &(m_pVertices[0]);
	//pV->x = 0.0f;	pV->y = 0.0f;	pV->z = 0.0f;
	//pV->color = D3DCOLOR_XRGB(255, 0, 0);

	m_pVertices[0].x = 0.0f;
	m_pVertices[0].y = 0.0f;
	m_pVertices[0].z = 0.0f;

	float twoPi = 3.14159f * 2;
	float degStep = twoPi / (float)cantCaras;
	float angle = 0;


	for(int i=1; i< cantCaras+2; i++)
	{
		/*double degreesToRadians = 3.14159265f / 180.0f;

		double dAngle = (360.0 / cantCaras) * i;
		double dAngSin = sin(dAngle * degreesToRadians);
		double dAngCos = cos(dAngle * degreesToRadians);
/**/
		/*pV = &(m_pVertices[i]);
		pV->x = (float)(dAngSin) * 0.1f;//asi el setScale de renderer tiene algo de sentido y no tengo q poner 0.1
		pV->y = (float)(dAngCos) * 0.1f;
		pV->z = 0.0f;*/
		//pV->color = D3DCOLOR_XRGB(255, 0, 0);
		angle = twoPi/ cantCaras * i;
		
		m_pVertices[i].x = sin(angle);
		m_pVertices[i].y = cos(angle);
		m_pVertices[i].z = 0.0f;
		
		/*m_pVertices[i].x = sin(dAngSin);
		m_pVertices[i].y = cos(dAngCos);
		m_pVertices[i].z = 0.0f;*/
	}
	Entity2D::setScale(Entity2D::getScaleW(), Entity2D::getScaleH());
}
